import unittest
from tools.tools_1 import Chrome
from page.login_page import LoginPage
from page.index_page import IndexPage
from time import sleep

class BaseCase(unittest.TestCase):
    def setUp(self):
        self.driver = Chrome()
        # 封装公共登录方法
    def login(self, username, password):
        lp = LoginPage(self.driver)
        lp.open()
        lp.input_username(username)
        sleep(1)
        lp.input_password(password)
        sleep(1)
        lp.click_btn()
        sleep(1)

        # 封装“登录后进入任务页面”的公共流程
    def task_page(self, username, password):
        self.login(username, password)  # 复用登录方法
        ip = IndexPage(self.driver)
        ip.click_task()
        sleep(1)
        # 封装“登录后进入产品页面”的公共流程
    def product_page(self, username, password):
        self.login(username, password)  # 复用登录方法
        ip = IndexPage(self.driver)
        ip.click_product()
        sleep(1)
        # 封装“登录后进入日志页面”的公共流程
    def log_page(self, username, password):
        self.login(username, password)  # 复用登录方法
        ip = IndexPage(self.driver)
        ip.click_btn_more()
        sleep(1)
        ip.click_log()
        sleep(1)
    def tearDown(self):
        self.driver.quit()